package com.learn.kafka;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import java.util.concurrent.TimeUnit;

/**
 * Hello world!
 */
@SpringBootApplication
public class SpringKafkaPartitionApplication {

    public static void main(String[] args) throws InterruptedException {
        ConfigurableApplicationContext context = SpringApplication.run(SpringKafkaPartitionApplication.class, args);

        KafkaProducer kafkaProducer = context.getBean(KafkaProducer.class);

        for (int i = 0; i < 10; i++) {
            kafkaProducer.sendMessage("test-topic", "message-" + i);
            TimeUnit.SECONDS.sleep(2);
        }
    }
}
